/**************************************************************************/
/*                                                                        */
/* Copyright (c) Sinoembed Technology Co.,Ltd.           */
/*  */
/*                                                                        */
/*                                                                        */
/*    created:    2012-6-27                                             */ 
/*    filename:   CSinoembedPuzzleWnd.h                                          */ 
/*    author:     Derek Huang                                                  */  
/*    purpose:                                                            */ 
/*                                                                        */
/* ************************************************************************/

#ifndef __CE_BLUETOOTH_WND_H__
#define __CE_BLUETOOTH_WND_H__
#include <mzfc_inc.h>
//#include "iUiButton.h"
#include "UiBTTopBar.h"
#include "UiCtrlWnd.h"
#include "UiDialPanelWnd.h"
#include "UiPhonebookWnd.h"
#include "UiCallRecWnd.h"

#define IVTBC6

#ifdef IVTBC6
#include "CBase.h"
#include "ManagerPhoneBookItem.h"
#endif
typedef enum _tagBlueToothWndDisplay
{
	BLUETOOTH_TOPBAR_WND = 0,
	BLUETOOTH_DIALPANLE_WND,
	BLUETOOTH_PHONEBOOK_WND,
	BLUETOOTH_CALLREC_WND,
	BLUETOOTH_CTRL_WND,
	MAX_BLUETOOTH_WND,
} BLUETOOTH_WND;

typedef enum _tagDialSource
{
	DIAL_SOURCE_DIAL_PANEL = 0,
	DIAL_SOURCE_PHONE_BOOK,
	DIAL_SOURCE_RECORD_OUT,
	DIAL_SOURCE_RECORD_IN,
	DIAL_SOURCE_RECORD_MISSED,
	MAX_DIAL_SOURCE,
} DIAL_SOURCE;

typedef enum _tagCallRecType
{
	CALL_RECORD_OUT,
	CALL_RECORD_IN,
	CALL_RECORD_MISSED,
	MAX_CALL_RECORD_TYPE,
}CALLRECTYPE;

typedef enum _tagDeviceConnectState
{
	DEVICE_STATE_CONNECT_HF,
	DEVICE_STATE_CONNECT_A2DP,
	DEVICE_STATE_CONNECT_INTERNET,
	DEVICE_STATE_CONNECT_FTP,
	DEVICE_STATE_CONNECT_SPP,
	DEVICE_STATE_CONNECT_STREAMSTART,
	DEVICE_STATE_CONNECT_PAIRED,
	DEVICE_STATE_DISCONNECT_HP,
	DEVICE_STATE_DISCONNECT_A2DP,
	DEVICE_STATE_DISCONNECT_INTERNET,
	DEVICE_STATE_DISCONNECT_FTP,
	DEVICE_STATE_DISCONNECT_SPP,
	DEVICE_STATE_DISCONNECT_STREAMOVER,
	DEVICE_STATE_INCOMMING,
	DEVICE_STATE_ONGOING_CALL,
	DEVICE_STATE_STANDBY,
	DEVICE_STATE_OUTGOING_CALL,
}DEVICECONNECTSTATE;

typedef struct _tagCallNumRecItem
{
	DWORD		dwCurrNumType;
	TCHAR		strTelNum[255];
	SYSTEMTIME	Time;
} CALL_NUM_REC_ITEM, *PCALL_NUM_REC_ITEM;

#define CALLNUM_INCOMING	0x1
#define CALLNUM_OUTGOING	0x10
#define CALLNUM_ONGOING		0x100
class CSinoembedBlueToothWnd : public CMzWndEx
{
public:
	CSinoembedBlueToothWnd();
	virtual ~CSinoembedBlueToothWnd();
	virtual void PaintWin(HDC hdc, RECT* prcUpdate /* = NULL */);
	virtual BOOL OnInitDialog();
	virtual  void OnMzCommand(WPARAM wParam, LPARAM lParam);
	virtual LRESULT MzDefWndProc(UINT message, WPARAM wParam, LPARAM lParam);
	void AnimateWindowEx_In( UINT nAnimType, bool bShow );
	void AnimateWindowEx_Out( UINT nAnimType, bool bShow );
	virtual void OnLButtonDown(UINT fwKeys, int xPos, int yPos);
	virtual void DeleteImages();
	void DestroyWindow();
private:

public:
#ifdef MERGER_APP_TO_SHELL
	BOOL Create();
#endif
	BOOL InitBackgrandImages();
	void LoadiInterItem();
	void OnExit();
	void OnMenu();
	void ShowMainWnd(BOOL bShow);
	void ShowOnlyWnd(UINT nWndIndex);
	void PostMessage2App4Source();
public:
	HDC				m_hBakDC;
	HDC				m_hBakDC2;
	ImagingHelper	*m_BTMainBG;
	ImagingHelper	*m_DialPanelBG;
	ImagingHelper	*m_PhoneBookBG;
	HBITMAP			m_hBitmapBakDC;
public:
	UiWin		m_uiWin;
	UiBTTopBar	m_uiTopBar;
	UiCtrlWnd	m_uiCtrlWnd;
	UiDialPanelWnd	m_uiDialPanelWnd;
	UiPhoneBookWnd	m_uiPhoneBookWnd;
	UiCallRecWnd	m_uiCallRecWnd;

#ifdef IVTBC6
public:
	void StartupBluetoothDevice();
	void CloseBluetoothDevice();
	static long DeviceConnect_CbkFunc(BOOL IsConnected,unsigned char* bd_addr,short svc_class);
	static long DevicePair_CbkFunc(BOOL IsPaired, unsigned char *bd_addr);
	static void HandsFree_CbkFunc(int nMsgId,void *pArg);
	static void UpdateResult_CbFunc(long errCode);
	static DWORD HandleStartup(LPVOID pParam );
//	WM_IVTOUTMSG_DIALERSTATE
	void IvtOutMsgDialerContent(WPARAM wParam, LPARAM lParam);
	void SetCurrConnectState(DWORD dwConState){m_dCurrConnectState = dwConState;};
	DWORD GetCurrConnectState(){return m_dCurrConnectState;};
public:
	BOOL	m_bInitState;
	DWORD	m_dCurrConnectState;
//Cmd Wnd
public:
	void DialOnCmd();
	void DialOnKeyCmd(UINT nCtrl);
	void HangupCmd();
	void SetDialSource(DWORD dwDialSource) {m_dwDialSource = dwDialSource;};
	DWORD GetDialSource() {return m_dwDialSource;};
	DWORD m_dwDialSource;
//Phone Book
public:
	void SyncPhoneBookCmd();
	void SyncPhoneBookContent();
	void SearchPhoneBookCmd();
	void DelOneItemPhoneBookCmd();
	void DelAllItemPhoneBookCmd();
	void DestroyPhoneBookManagerList();
	void DestroyPhoneBookList();
	void LoadPhoneBookFromExtStroage();
	void SavePhoneBookFromExtStroage();
	UINT	m_SyncPhoneBookCount;
	DWORD	m_nRingTime;
	CManagerPhoneBookItem m_ManagerPhoneBookItem;

//Call Record
public:
	void SetCallRecType(UINT nType);
	UINT GetCallRecType(){return m_nCurrCallRecTypeWnd;};
	void DestroyCallRecManagerList(UINT nType);
	void DestroyCallRecList();
	void AddOneItemCallRecCmd(UINT nType);
	void DelOneItemCallRecCmd(UINT nType);
	void CreateCallRecList(UINT nType);
	void SaveCallRec(DWORD dwValue);
	BOOL IsTelNumInPhoneBook(CFileItem *pFileItem);
	void LoadCallRecFromExtStroage();
	void SaveCallRecFromExtStroage();
public:
	UINT m_nCurrCallRecTypeWnd;
	UINT m_nOldCallRecTypeWnd;
	CManagerPhoneBookItem m_ManagerCallRecordItem[MAX_CALL_RECORD_TYPE];
	CALL_NUM_REC_ITEM	m_currCallNumRecItem;
#endif

	BOOL ReloadBkgnd();
};


#endif
